package com.ocean.product.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName: HeatMap
 * @Description: 热力图
 * @Author: liu
 * @Date: 2024-03-13
 * @Version: 1.0
 **/

@Data
@AllArgsConstructor
@NoArgsConstructor
public class HeatMap {
    private double longitude;
    private double latitude;
    private double value;
    private String dataType;
    private String areaCode;

    public HeatMap(double longitude, double latitude, double value) {
        this.longitude = roundToTwoDecimals(longitude);
        this.latitude = roundToTwoDecimals(latitude);
        this.value = roundToTwoDecimals(value);
    }

    private double roundToTwoDecimals(double value) {
        //性能最好，适用于对精度要求不高的场景
        return Math.round(value * 100.0) / 100.0;
    }
   /* private double roundToTwoDecimals(double value) {
        //性能较差，但精度高，适用于金融计算等高精度要求的场景。
        return new BigDecimal(value)
                .setScale(2, RoundingMode.HALF_UP)
                .doubleValue();
    }*/
}
